*** IMPORT DATA ***
clear
use "${here}KuttnerData.dta", clear

*** CHANGE SETTINGS FOR GRAPHS
set more off, permanently
grstyle init
grstyle set plain, horizontal nogrid
graph set window fontface "Helvetica"

***************************
*** TREATMENT VARIABLES ***
***************************

*** CREATE TREATMENT VARIABLE
gen Treatment = 0
replace Treatment = 1 if V1_Timing_PageSubmit ~= .
replace Treatment = 2 if V2_Timing_PageSubmit ~= .
replace Treatment = 3 if V3_Timing_PageSubmit ~= .
replace Treatment = 4 if V4_Timing_PageSubmit ~= .
replace Treatment = 5 if V5_Timing_PageSubmit ~= .

label define treatments 1 "A: No Pronouns/Labels" 2 "B: He/Transgender" 3 "C: He/Nonbinary" 4 "D: They/Transgender" 5 "E: They/Nonbinary"
label values Treatment treatments

*** CREATE ISOLATED TREATMENT VARIABLES
gen PronounsTreatment = 0
replace PronounsTreatment = 1 if V4_Timing_PageSubmit ~= .
replace PronounsTreatment = 1 if V5_Timing_PageSubmit ~= .
replace PronounsTreatment = 2 if V2_Timing_PageSubmit ~= .
replace PronounsTreatment = 2 if V3_Timing_PageSubmit ~= .

label define pronouns 0 "A: No Pronouns" 1 "DE: They/Them" 2 "BC: He/Him"
label values PronounsTreatment pronouns

gen LabelsTreatment = 0
replace LabelsTreatment = 1 if V2_Timing_PageSubmit ~= .
replace LabelsTreatment = 1 if V4_Timing_PageSubmit ~= .
replace LabelsTreatment = 2 if V3_Timing_PageSubmit ~= .
replace LabelsTreatment = 2 if V5_Timing_PageSubmit ~= .

label define identitylabels 0 "A: No Labels" 1 "BD: Transgender" 2 "CE: Nonbinary"
label values LabelsTreatment identitylabels

*************************
*** OUTCOME VARIABLES ***
*************************

*** GENDER ATTRIBUTIONS
gen KuttnerMan = 0
replace KuttnerMan = 1 if regexm(C1, "Man")
label variable KuttnerMan "Gender Attribution: Man"

gen KuttnerWoman = 0
replace KuttnerWoman = 1 if regexm(C1, "Woman")
label variable KuttnerWoman "Gender Attribution: Woman"

gen KuttnerTransgender = 0
replace KuttnerTransgender = 1 if regexm(C1, "Transgender")
label variable KuttnerTransgender "Gender Attribution: Transgender"

gen KuttnerNonbinary = 0
replace KuttnerNonbinary = 1 if regexm(C1, "Nonbinary")
label variable KuttnerNonbinary "Gender Attribution: Nonbinary"

*** GENERATE LIKELIHOOD TO VOTE
gen LikelihoodVote = D1_1

*** GENERATE TRAIT OUTCOMES
gen Honesty = D2_1
gen Compassionate = D3_1
gen Competence = D4_1
gen Intelligence = D5_1

gen CharacterScale = (Honesty + Compassionate) / 2
gen CompetenceScale = (Competence + Intelligence) / 2

label variable CharacterScale "Character Scale (0-10)"
label variable CompetenceScale "Competence Scale (0-10)"

****************************************************************
*** VARIABLES FOR HETEROGENOUS TREATMENT EFFECTS AND WEIGHTS ***
****************************************************************

gen Age4 = .
replace Age4 = 1 if A1 == "18-24"
replace Age4 = 2 if A1 == "25-44"
replace Age4 = 3 if A1 == "45-64"
replace Age4 = 4 if A1 == "65 and older"

label define ages 1 "18-24" 2 "25-44" 3 "45-64" 4 "65 and older"
label values Age4 ages

*** PARTY IDENTIFICATION
** RECODE CLOSE-ENDED RESPONSES
gen PartyID = .
replace PartyID = 0 if A3 == "None of these"
replace PartyID = 1 if A3 == "Liberal"
replace PartyID = 2 if A3 == "Conservative"
replace PartyID = 3 if A3 == "NDP"
replace PartyID = 4 if A3 == "Bloc quÃ©bÃ©cois"
replace PartyID = 5 if A3 == "Green"
replace PartyID = 6 if A3 == "Another party (please specify)"

** RECODE PPC TO SAME AS CONSERVATIVE (21 RESPONDENTS)
gen PartyID_Upper = upper(A3_6_TEXT)
replace PartyID = 2 if regexm(PartyID_Upper, "PEOPLE'S PARTY")
replace PartyID = 2 if regexm(PartyID_Upper, "PEOPEL PARTY")
replace PartyID = 2 if regexm(PartyID_Upper, "PEOPLES PARTY")
replace PartyID = 2 if regexm(PartyID_Upper, "PEOPLE PARTY")
replace PartyID = 2 if regexm(PartyID_Upper, "PPC")
replace PartyID = 2 if regexm(PartyID_Upper, "PEOPLE'S")
replace PartyID = 2 if regexm(PartyID_Upper, "MAX BERNIES")

label define parties 0 "None" 1 "Liberal" 2 "Conservative/PPC" 3 "NDP" 4 "BQ" 5 "Green" 6 "Other"
label values PartyID parties

*** GENDER IDENTITY
gen GenderID = 1 if A4 == "A man"
replace GenderID = 2 if A4 == "A woman"
replace GenderID = 3 if A4 == "Non-binary" | regexm(A4, "Another gender")

label define genders 1 "Man" 2 "Woman" 3 "Nonbinary"
label values GenderID genders

*** UNIVERSITY EDUCATION
gen Education = 0
replace Education = 1 if A7 == "Bachelor's degree" | ///
						A7 == "Master's degree" | ///
						A7 == "Professional degree or doctorate"
replace Education = . if A7 == "Prefer not to answer"
						
label define educations 0 "No University" 1 "University"
label values Education educations
						
*** LGBTQ IDENTITY
gen LGBTQ = 0
replace LGBTQ = 1 if GenderID == 3 | ///
						A5 == "Yes" | ///
						A6 == "Gay or lesbian" | ///
						A6 == "Asexual" | ///
						A6 == "Bisexual" | ///
						A6 == "Pansexual" | ///
						A6 == "Queer" | ///
						A6 == "Something else (please specify)"

tab A6_7_TEXT
replace LGBTQ = 0 if A6_7_TEXT == "straight"

label define lgbtqs 0 "Non-LGBTQ+" 1 "LGBTQ+"
label values LGBTQ lgbtqs

*** MOTHER TONGUE
gen EnglishMotherTongue = 1
replace EnglishMotherTongue = 2 if regexm(A8, "English")
tab EnglishMotherTongue

gen FrenchMotherTongue = 1
replace FrenchMotherTongue = 2 if regexm(A8, "French")
tab FrenchMotherTongue

gen OtherMotherTongue = 1
replace OtherMotherTongue = 2 if regexm(A8, "Other")
tab OtherMotherTongue

*** REGION
gen Region = .
replace Region = 1 if A2 == "Newfoundland and Labrador" | ///
						A2 == "Nova Scotia" | ///
						A2 == "Prince Edward Island" | ///
						A2 == "New Brunswick"
replace Region = 2 if A2 == "Quebec"
replace Region = 3 if A2 == "Ontario"
replace Region = 4 if A2 == "Manitoba" | ///
						A2 == "Saskatchewan" | ///
						A2 == "Alberta"
replace Region = 5 if A2 == "British Columbia"

label define regions 1 "Atlantic" 2 "Quebec" 3 "Ontario" 4 "Prairies" 5 "BC"
label values Region regions

*** RACE/ETHNICITY DUMMIES
gen White = 0
replace White = 1 if regexm(A9, "White")

gen Arab = 0
replace Arab = 1 if regexm(A9, "Arab")

gen Black = 0
replace Black = 1 if regexm(A9, "Black")

gen EastAsian = 0
replace EastAsian = 1 if regexm(A9, "East Asian")

gen Indigenous = 0
replace Indigenous = 1 if regexm(A9, "Indigenous")

gen Latine = 0
replace Latine = 1 if regexm(A9, "Latin")

gen SouthAsian = 0
replace SouthAsian = 1 if regexm(A9, "South Asian")

gen SoutheastAsian = 0
replace SoutheastAsian = 1 if regexm(A9, "Southeast Asian")

gen WestAsian = 0
replace WestAsian = 1 if regexm(A9, "West Asian")

gen OtherRace = 0
replace OtherRace = 1 if regexm(A9, "Other")

gen MissingRace = 0
replace MissingRace = 1 if regexm(A9, "know") | regexm(A9, "Prefer not to answer")

****************
*** FIGURE 1 ***
****************

preserve
gen Count = 1
collapse (sum) KuttnerMan KuttnerWoman KuttnerTransgender KuttnerNonbinary Count, by(Treatment)

gen ManPercent = (KuttnerMan / Count) * 100
gen WomanPercent = (KuttnerWoman / Count) * 100
gen TransgenderPercent = (KuttnerTransgender / Count) * 100
gen NonbinaryPercent = (KuttnerNonbinary / Count) * 100

graph hbar WomanPercent, over(Treatment, relabel(1 "Control" 2 "He/Transgender" 3 "He/Nonbinary" 4 "They/Transgender" 5 "They/Nonbinary") label(labsize(vlarge))) ///
	bar(1, color(black)) ///
	ytitle("") ///
	yscale(range(0 80)) ///
	ylabel(0(20)80, labsize(vlarge)) ///
	title("Woman", size(vlarge))
graph save "KuttnerWoman.gph", replace

graph hbar ManPercent, over(Treatment, relabel(1 " " 2 " " 3 " " 4 " " 5 " ") 	label(labsize(vlarge))) ///
	bar(1, color(black)) ///
	ytitle("") ///
	yscale(range(0 80)) ///
	ylabel(0(20)80, labsize(vlarge)) ///
	title("Man", size(vlarge)) ///
	fxsize(25.9)
graph save "KuttnerMan.gph", replace

graph hbar TransgenderPercent, over(Treatment, relabel(1 " " 2 " " 3 " " 4 " " 5 " ")	label(labsize(vlarge))) ///
	bar(1, color(black)) ///
	ytitle("") ///
	yscale(range(0 80)) ///
	ylabel(0(20)80, labsize(vlarge)) ///
	title("Transgender", size(vlarge)) ///
	fxsize(25.9)
graph save "KuttnerTransgender.gph", replace

graph hbar NonbinaryPercent, over(Treatment, relabel(1 " " 2 " " 3 " " 4 " " 5 " ") label(labsize(vlarge))) ///
	bar(1, color(black)) ///
	ytitle("") ///
	yscale(range(0 80)) ///
	ylabel(0(20)80, labsize(vlarge)) ///
	title("Nonbinary", size(vlarge)) ///
	fxsize(25.9)
graph save "KuttnerNonbinary.gph", replace

graph combine KuttnerWoman.gph KuttnerMan.gph KuttnerTransgender.gph KuttnerNonbinary.gph, col(4) b1title("Percentage Selecting Each Gender Attribution", size(medlarge))
graph export "Figure1.png", height(400) width(1000) replace
graph export "fg1.eps", replace
restore

****************************************************************
*** TABLE 2: HYPOTHESIS TESTS, INSTRUMENTAL VARIABLES MODELS ***
****************************************************************

** RUN INSTRUMENTAL VARIABLES REGRESSION (8B, 8C)
ivregress 2sls CompetenceScale (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment)
** HYPOTHESIS H1 (in paper)/8B (PAP): coefficient for KuttnerMan
** HYPOTHESIS H3 (in paper)/8C (PAP): claim about nonbinary people vs. women = coefficient for KuttnerNonbinary

*** DERIVED QUANTITITES TO TEST ADDITIONAL HYPOTHESES
** HYPOTHESIS H2 (in paper)/8C (PAP): claim about nonbinary people vs. men
lincom 1.KuttnerMan - 1.KuttnerNonbinary

** HYPOTHESIS H4 (in paper)/8D (PAP)
lincom 1.KuttnerTransgender - ((0 + 1.KuttnerMan + 1.KuttnerNonbinary)/3) 
* 0 indicates the KuttnerWoman condition

** HYPOTHESIS H5 (in paper)/8E (PAP)
lincom 1.KuttnerNonbinary - ((0 + 1.KuttnerMan + 1.KuttnerTransgender)/3) 
* 0 indicates the KuttnerWoman condition

** Unintentional Result mentioned in text
lincom 1.KuttnerMan - 1.KuttnerTransgender

******************
*** APPENDICES ***
******************

*************************************
*** APPENDIX C: COVARIATE BALANCE ***
*************************************

tab Age4 Treatment, col chi
tab GenderID Treatment, col chi
tab Education Treatment, col chi
tab PartyID Treatment, col chi
tab Region Treatment, col chi
tab A6 Treatment, col chi
tab A5 Treatment, col chi 
tab LGBTQ Treatment, col chi

tab White Treatment, col chi
tab Arab Treatment, col chi
tab Black Treatment, col chi
tab EastAsian Treatment, col chi
tab Indigenous Treatment, col chi
tab Latine Treatment, col chi
tab SouthAsian Treatment, col chi
tab SoutheastAsian Treatment, col chi
tab WestAsian Treatment, col chi
tab OtherRace Treatment, col chi
tab MissingRace Treatment, col chi

tab EnglishMotherTongue Treatment, col chi
tab FrenchMotherTongue Treatment, col chi
tab OtherMotherTongue Treatment, col chi

**********************************************************
*** APPENDIX D: CHECK FOR MULTIPLE GENDER ATTRIBUTIONS ***
**********************************************************

gen GenderAttributions = .
replace GenderAttributions = 1 if KuttnerWoman == 1
replace GenderAttributions = 2 if KuttnerMan == 1
replace GenderAttributions = 3 if KuttnerTransgender == 1
replace GenderAttributions = 4 if KuttnerNonbinary == 1
replace GenderAttributions = 5 if KuttnerWoman == 1 & KuttnerMan == 1
replace GenderAttributions = 6 if KuttnerWoman == 1 & KuttnerTransgender == 1
replace GenderAttributions = 7 if KuttnerWoman == 1 & KuttnerNonbinary == 1
replace GenderAttributions = 8 if KuttnerMan == 1 & KuttnerTransgender == 1
replace GenderAttributions = 9 if KuttnerMan == 1 & KuttnerNonbinary == 1
replace GenderAttributions = 10 if KuttnerTransgender == 1 & KuttnerNonbinary == 1
replace GenderAttributions = 11 if KuttnerWoman == 1 & KuttnerMan == 1 & KuttnerTransgender == 1
replace GenderAttributions = 12 if KuttnerWoman == 1 & KuttnerMan == 1 & KuttnerNonbinary == 1
replace GenderAttributions = 13 if KuttnerWoman == 1 & KuttnerTransgender == 1 & KuttnerNonbinary == 1
replace GenderAttributions = 14 if KuttnerMan == 1 & KuttnerTransgender == 1 & KuttnerNonbinary == 1
replace GenderAttributions = 15 if KuttnerWoman == 1 & KuttnerMan == 1 & KuttnerTransgender == 1 & KuttnerNonbinary == 1
replace GenderAttributions = 16 if KuttnerWoman == 0 & KuttnerMan == 0 & KuttnerTransgender == 0 & KuttnerNonbinary == 0

label define attributions 1 "Woman Only" /// 
			2 "Man Only" ///
			3 "Transgender Only" ///
			4 "Nonbinary Only" ///
			5 "Woman, Man" ///
			6 "Woman, Transgender" ///
			7 "Woman, Nonbinary" ///
			8 "Man, Transgender" ///
			9 "Man, Nonbinary" ///
			10 "Transgender, Nonbinary" ///
			11 "Woman, Man, Transgender" ///
			12 "Woman, Man, Nonbinary" ///
			13 "Woman, Transgender, Nonbinary" ///
			14 "Man, Transgender, Nonbinary" ///
			15 "Woman, Man, Transgender, Nonbinary" ///
			16 "None"
label values GenderAttributions attributions
tab GenderAttributions

gen NumberAttributions = 0 if GenderAttributions < 5
replace NumberAttributions = 1 if GenderAttributions > 4 & GenderAttributions < 16
replace NumberAttributions = 2 if GenderAttributions == 16
label define numberattributions 0 "Only One Attribution" 1 "Multiple Attributions" 2 "No Attributions"
label values NumberAttributions numberattributions
tab NumberAttributions

********************************************************
*** BEFORE APPENDIX E: CONSTRUCTION OF RAKED WEIGHTS ***
*** TARGET: ENGLISH-SPEAKING CANADIAN ADULTS ***********
********************************************************

*** GENERATE STARTING WEIGHT FOR IPFRAKING
* 1/2000
gen StartingWeight = 0.0005

*** GENERATE ONE VARIABLE FOR IPFRAKING 
gen One = 1

*** AGE
matrix Census2021Age = ( ///
                     6.46, ///
                     45.33, ///
                     29.77, ///
                     18.44)

matrix rownames Census2021Age = Age
matrix colnames Census2021Age = 1 2 3 4
matrix roweq Census2021Age = "_"
matrix coleq Census2021Age = "One" "One" "One" "One"

*** GENDER
matrix Census2021Gender = ( ///
                     49.6527, ///
                     50.2119, ///
                     0.1354)

matrix rownames Census2021Gender = GenderID
matrix colnames Census2021Gender = 1 2 3
matrix roweq Census2021Gender = "_"
matrix coleq Census2021Gender = "One" "One" "One"
					 
* 2021 Census PUMF does not include data on nonbinary people due to data privacy concerns
* Matrix reweights men and women to set the target for nonbinary people as 0.1354% based on information reported at https://www150.statcan.gc.ca/n1/daily-quotidien/220427/dq220427b-eng.htm

*** REGION
matrix Census2021Region = ( ///
                     7.33, ///
                     14.44, ///
                     43.12, ///
					 19.94, ///
					 15.17)

matrix rownames Census2021Region = Region
matrix colnames Census2021Region = 1 2 3 4 5
matrix roweq Census2021Region = "_"
matrix coleq Census2021Region = "One" "One" "One" "One" "One"

*** ENGLISH MOTHER TONGUE
matrix Census2021EnglishMotherTongue = ( ///
					34.86, ///
					65.14)

matrix rownames Census2021EnglishMotherTongue = EnglishMotherTongue
matrix colnames Census2021EnglishMotherTongue = 1 2
matrix roweq Census2021EnglishMotherTongue = "_"
matrix coleq Census2021EnglishMotherTongue = "One" "One"

*** FRENCH MOTHER TONGUE
matrix Census2021FrenchMotherTongue = ( ///
					87.07, ///
					12.93)

matrix rownames Census2021FrenchMotherTongue = FrenchMotherTongue
matrix colnames Census2021FrenchMotherTongue = 1 2
matrix roweq Census2021FrenchMotherTongue = "_"
matrix coleq Census2021FrenchMotherTongue = "One" "One"
					
*** OTHER MOTHER TONGUE
matrix Census2021OtherMotherTongue = ( ///
					74.96, ///
					25.04)

matrix rownames Census2021OtherMotherTongue = OtherMotherTongue
matrix colnames Census2021OtherMotherTongue = 1 2
matrix roweq Census2021OtherMotherTongue = "_"
matrix coleq Census2021OtherMotherTongue = "One" "One"
					
*** FEED MATRICESINTO IPFRAKING
ipfraking [pweight=StartingWeight], ctotal(Census2021Age Census2021Gender Census2021Region Census2021EnglishMotherTongue Census2021FrenchMotherTongue Census2021OtherMotherTongue) gen(RakedWeight) trimhiabs(5000)

*************************************************************
*** APPENDIX E: TREATMENT EFFECTS AND GENDER ATTRIBUTIONS ***
*************************************************************

*** TABLE E1: PRONOUNS TREATMENTS AND GENDER ATTRIBUTIONS
regress KuttnerMan i.PronounsTreatment
margins i.PronounsTreatment, pwcompare(pveffects)

regress KuttnerWoman i.PronounsTreatment
margins i.PronounsTreatment, pwcompare(pveffects)

regress KuttnerTransgender i.PronounsTreatment
margins i.PronounsTreatment, pwcompare(pveffects)

regress KuttnerNonbinary i.PronounsTreatment
margins i.PronounsTreatment, pwcompare(pveffects)

*** TABLE E2: LABELS TREATMENTS AND GENDER ATTRIBUTIONS
regress KuttnerMan i.LabelsTreatment
margins i.LabelsTreatment, pwcompare(pveffects)

regress KuttnerWoman i.LabelsTreatment
margins i.LabelsTreatment, pwcompare(pveffects)

regress KuttnerTransgender i.LabelsTreatment
margins i.LabelsTreatment, pwcompare(pveffects)

regress KuttnerNonbinary i.LabelsTreatment
margins i.LabelsTreatment, pwcompare(pveffects)

*** TABLE E3: ALL TREATMENTS
regress KuttnerMan i.Treatment
margins i.Treatment, pwcompare(pveffects)

regress KuttnerWoman i.Treatment
margins i.Treatment, pwcompare(pveffects)

regress KuttnerTransgender i.Treatment
margins i.Treatment, pwcompare(pveffects)

regress KuttnerNonbinary i.Treatment
margins i.Treatment, pwcompare(pveffects)

*** TABLE E4: PRONOUNS TREATMENTS AND GENDER ATTRIBUTIONS (WEIGHTED)
regress KuttnerMan i.PronounsTreatment [pweight = RakedWeight]
margins i.PronounsTreatment, pwcompare(pveffects)

regress KuttnerWoman i.PronounsTreatment [pweight = RakedWeight]
margins i.PronounsTreatment, pwcompare(pveffects)

regress KuttnerTransgender i.PronounsTreatment [pweight = RakedWeight]
margins i.PronounsTreatment, pwcompare(pveffects)

regress KuttnerNonbinary i.PronounsTreatment [pweight = RakedWeight]
margins i.PronounsTreatment, pwcompare(pveffects)

*** TABLE E5: LABELS TREATMENTS AND GENDER ATTRIBUTIONS (WEIGHTED)
regress KuttnerMan i.LabelsTreatment [pweight = RakedWeight]
margins i.LabelsTreatment, pwcompare(pveffects)

regress KuttnerWoman i.LabelsTreatment [pweight = RakedWeight]
margins i.LabelsTreatment, pwcompare(pveffects)

regress KuttnerTransgender i.LabelsTreatment [pweight = RakedWeight]
margins i.LabelsTreatment, pwcompare(pveffects)

regress KuttnerNonbinary i.LabelsTreatment [pweight = RakedWeight]
margins i.LabelsTreatment, pwcompare(pveffects)

*** TABLE E6: ALL TREATMENTS (WEIGHTED)
regress KuttnerMan i.Treatment [pweight = RakedWeight]
margins i.Treatment, pwcompare(pveffects)

regress KuttnerWoman i.Treatment [pweight = RakedWeight]
margins i.Treatment, pwcompare(pveffects)

regress KuttnerTransgender i.Treatment [pweight = RakedWeight]
margins i.Treatment, pwcompare(pveffects)

regress KuttnerNonbinary i.Treatment [pweight = RakedWeight]
margins i.Treatment, pwcompare(pveffects)

***********************************************************
*** APPENDIX F: ADDITIONAL RESULTS FOR COMPETENCE SCALE ***
***********************************************************

** HYPOTHESIS 8A
regress CompetenceScale i.Treatment
estimates store A
esttab A using "${here}CompetenceScaleLinearProbabilityModel.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

*** WEIGHTED
** HYPOTHESIS 8A
regress CompetenceScale i.Treatment [pweight = RakedWeight]
estimates store A
esttab A using "${here}CompetenceScaleLinearProbabilityModelWeighted.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

** HYPOTHESES 8B-8E
** INSTRUMENTAL VARIABLES UNWEIGHTED
ivregress 2sls CompetenceScale (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment)
estimates store A
esttab A using "${here}CompetenceScaleInstrumentalVariablesUnweighted.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

** INSTRUMENTAL VARIABLES WEIGHTED
ivregress 2sls CompetenceScale (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment) [pweight = RakedWeight]
estimates store A
esttab A using "${here}CompetenceScaleInstrumentalVariablesWeighted.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

** Hypothesis 8C
lincom 1.KuttnerMan - 1.KuttnerNonbinary

** Hypothesis 8D
lincom ((0 + 1.KuttnerMan + 1.KuttnerNonbinary)/3) - 1.KuttnerTransgender
* 0 indicates the KuttnerWoman condition

** Hypothesis 8E
lincom ((0 + 1.KuttnerMan + 1.KuttnerTransgender)/3) - 1.KuttnerNonbinary
* 0 indicates the KuttnerWoman condition

** Unintentional Result
lincom 1.KuttnerMan - 1.KuttnerTransgender

****************************************
*** APPENDIX G: LIKELIHOOD OF VOTING ***
****************************************

regress LikelihoodVote i.Treatment
estimates store A
esttab A using "${here}LikelihoodVoteLinearProbabilityModel.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

ivregress 2sls LikelihoodVote (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment)
estimates store A
esttab A using "${here}LikelihoodVoteInstrumentalVariablesModel.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

regress LikelihoodVote i.Treatment [pweight = RakedWeight]
estimates store A
esttab A using "${here}LikelihoodVoteLinearProbabilityModelWeighted.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

ivregress 2sls LikelihoodVote (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment) [pweight = RakedWeight]
estimates store A
esttab A using "${here}LikelihoodVoteInstrumentalVariablesModelWeighted.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

*** HETEROGENEOUS EFFECTS BY PARTY IDENTIFICATION ***
regress LikelihoodVote i.Treatment##i.PartyID

margins i.Treatment, at(PartyID == 0)
marginsplot, horizontal ///
	recast(scatter) ///
	plotopts(mcolor(black)) ///
	recastci(rspike) ///
	ciopts(lcolor(black)) ///
	level(90) ///
	ytitle("") ///
	xtitle("Likelihood to Vote Green") ///
	title("Party ID: None", size(medsmall))
graph save VotePartyID0.gph, replace
	
margins i.Treatment, at(PartyID == 1)
marginsplot, horizontal ///
	recast(scatter) ///
	plotopts(mcolor(black)) ///
	recastci(rspike) ///
	ciopts(lcolor(black)) ///
	level(90) ///
	ytitle("") ///
	xtitle("Likelihood to Vote Green") ///
	title("Party ID: Liberal", size(medsmall))
graph save VotePartyID1.gph, replace
	
margins i.Treatment, at(PartyID == 2)
marginsplot, horizontal ///
	recast(scatter) ///
	plotopts(mcolor(black)) ///
	recastci(rspike) ///
	ciopts(lcolor(black)) ///
	level(90) ///
	ytitle("") ///
	xtitle("Likelihood to Vote Green") ///
	title("Party ID: Conservative/PPC", size(medsmall))
graph save VotePartyID2.gph, replace
	
margins i.Treatment, at(PartyID == 3)
marginsplot, horizontal ///
	recast(scatter) ///
	plotopts(mcolor(black)) ///
	recastci(rspike) ///
	ciopts(lcolor(black)) ///
	level(90) ///
	ytitle("") ///
	xtitle("Likelihood to Vote Green") ///
	title("Party ID: NDP", size(medsmall))
graph save VotePartyID3.gph, replace

margins i.Treatment, at(PartyID == 4)
marginsplot, horizontal ///
	recast(scatter) ///
	plotopts(mcolor(black)) ///
	recastci(rspike) ///
	ciopts(lcolor(black)) ///
	level(90) ///
	ytitle("") ///
	xtitle("Likelihood to Vote Green") ///
	title("Party ID: BQ", size(medsmall))
graph save VotePartyID4.gph, replace
	
margins i.Treatment, at(PartyID == 5)
marginsplot, horizontal ///
	recast(scatter) ///
	plotopts(mcolor(black)) ///
	recastci(rspike) ///
	ciopts(lcolor(black)) ///
	level(90) ///
	ytitle("") ///
	xtitle("Likelihood to Vote Green") ///
	title("Party ID: Green", size(medsmall))
graph save VotePartyID5.gph, replace
	
*** COMBINE GRAPHS
graph combine VotePartyID0.gph VotePartyID1.gph VotePartyID2.gph VotePartyID3.gph VotePartyID4.gph VotePartyID5.gph, col(2)
graph export "FigureG1.png", height(800) width(1200) replace

***********************************
*** APPENDIX H: CHARACTER SCALE ***
***********************************

ivregress 2sls CharacterScale (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment)
estimates store A
esttab A using "${here}CharacterScaleInstrumentalVariables.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

lincom 1.KuttnerNonbinary - 1.KuttnerMan

ivregress 2sls CharacterScale (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment) [pweight = RakedWeight]
estimates store A
esttab A using "${here}CharacterScaleInstrumentalVariablesWeighted.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

lincom 1.KuttnerNonbinary - 1.KuttnerMan

***************************
*** APPENDIX I: HONESTY ***
***************************

regress Honesty i.LabelsTreatment
estimates store A
esttab A using "${here}HonestyLinearProbabiliyModel.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

ivregress 2sls Honesty (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment)
estimates store A
esttab A using "${here}HonestyInstrumentalVariables.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

lincom 1.KuttnerTransgender - ((0 + 1.KuttnerMan + 1.KuttnerNonbinary)/3)
lincom 1.KuttnerNonbinary - ((0 + 1.KuttnerMan + 1.KuttnerTransgender)/3)

regress Honesty i.LabelsTreatment [pweight = RakedWeight]
estimates store A
esttab A using "${here}HonestyLinearProbabiliyModelWeighted.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

ivregress 2sls Honesty (i.KuttnerMan i.KuttnerTransgender i.KuttnerNonbinary = i.Treatment) [pweight = RakedWeight]
estimates store A
esttab A using "${here}HonestyInstrumentalVariablesWeighted.rtf", label b(%5.2f) ci(%5.2f) starlevels(* 0.1 ** 0.05 *** 0.01) nobaselevels replace

lincom 1.KuttnerTransgender - ((0 + 1.KuttnerMan + 1.KuttnerNonbinary)/3)
lincom 1.KuttnerNonbinary - ((0 + 1.KuttnerMan + 1.KuttnerTransgender)/3)

***********************************************
*** APPENDIX L: SPEEDING AND STRAIGHTLINING ***
***********************************************

*** TOTAL DURATION OF SURVEY
gen SurveyTime = Q_TotalDuration / 60
su SurveyTime, d

replace SurveyTime = 15 if SurveyTime > 15
histogram SurveyTime, width(1) start(0) bcolor(black) percent xlabel(0 5 10 15 "15+") xtitle("Survey Time (Minutes)")
graph export "HistogramSurveyTime.png", height(600) width(800) replace

gen Speeder = 0
replace Speeder = 1 if Q_TotalDuration < 100

*** TIMING
gen Timing = 0
replace Timing = V1_Timing_PageSubmit if Treatment == 1
replace Timing = V2_Timing_PageSubmit if Treatment == 2
replace Timing = V3_Timing_PageSubmit if Treatment == 3
replace Timing = V4_Timing_PageSubmit if Treatment == 4
replace Timing = V5_Timing_PageSubmit if Treatment == 5

gen TimingLimit = Timing
replace TimingLimit = 300 if Timing > 300
histogram TimingLimit, start(0) bcolor(black) percent width(10) xlabel(0 100 200 300 "300+") xtitle("Time on Treatment Page (Seconds)")
graph export "HistogramTimingTreatmentPage.png", height(600) width(800) replace

*** STRAIGHTLINING
gen Straightliner = 0
replace Straightliner = 1 if LikelihoodVote == Honesty & ///
							Honesty == Compassionate & ///
							Compassionate == Competence & ///
							Competence == Intelligence

tab Straightliner

gen NumberStraightliner = LikelihoodVote if Straightliner == 1

histogram NumberStraightliner, start(0) bcolor(black) percent width(1) xtitle("Number Selected on 0-10 Scales (Straightliners Only)")
graph export "HistogramNumberStraightliner.png", height(600) width(800) replace
